package cn.tedu.mall.search.test;

import java.util.Scanner;

public class HanNuoTa {
    public static void main(String[] args) {
        while (true) {
            System.out.println("想玩几层汉诺塔：");
            int n = new Scanner(System.in).nextInt();
            f(n);
        }
    }

    private static void f(int n) {
        f(n,"A","B","C");
    }

    private static void f(int n, String form, String mid, String to) {
        if (n == 1){
            System.out.printf("%s -> %s\n",form,to);
            return;
        }
        f(n-1,form,to,mid);
        f(1,form,mid,to);
        f(n-1,mid,form,to);
    }
}
